<? 
	if(isset($_POST['btngo']))
	{
		require("required/dbconnect.php");
		$pageno=$_POST['pageno'];
		header("Location:order_view.php?page=$pageno");
	}
	
			
	$title="View all offline sales"; 
	$pageid="1";
	$accessid="a00";
	
	require("required/dbconnect.php"); 
	require("required/function.php");
	require("required/header.php");
	
	checkAccess("allow_gift_management",1);
	
?>
<script src="required/js/jquery-1.4.2.js"></script>
<script src="required/js/common_javascript.js"></script>
<?	
		
	if(!empty($_GET['action']))
	{
		switch($_GET['action'])
		{
			case 1:
				$msg="<div class='dw_success'>Data inserted</div>";
				break;
			case 2:
				$msg="<div class='dw_success'>Data Deleted</div>";
				break;
			case 3:
				$msg="<div class='dw_success'>Data Updated</div>";
				break;	
			default:
				$msg="";
				break;
		}
		echo "<script>displayMsg('divMsg')</script>";	
	}else{
		$msg="";
	}
	
	

		
	if(empty($_GET['page']))
	{
		$page="1";
	}
	else
	{
		$page=$_GET['page'];
	}
	
	$totalperpage=30;

	$from=($page-1)*$totalperpage;	
	
	$get_dv=mysql_query("select * from os_discount_voucher_used where status=1 order by used_datetime desc limit $from,$totalperpage")or die(mysql_error());
	$get_total=mysql_query("select count(*) as result from os_discount_voucher_used where status=1")or die(mysql_error());		
	
	
?>
<table width="100%">

<?
	$count=mysql_result($get_total,0,"result");


	
?>
<td align="left" valign="top">
	<div class="title">View All Offline Purchase</div>
     <div id="divMsg"><?= $msg ?></div>
	<table width="100%" cellpadding="2" cellspacing="1" >
		
		<? if(mysql_num_rows($get_dv)==0){ ?>
		<tr>
		 <td height="200" valign="middle" colspan="8" align="center">
			<font color="#FF0000">- No order found -</font><br>
		 </td>
		</tr>
		<? }else{ ?>
		<tr>
            <td width="100%" colspan="6" align="left"><br><br>
                <table width="100%" cellpadding="0" cellspacing="0" >
                    <td width="51%" height="45">
                  	 <?= getPaging($totalperpage,$count,$page,"dv_used_list.php?param=ntg") ?>
                    
                    </td>
                
              </table>
            </td>
        </tr>
		<tr>
        	<td width="100%" colspan="4">
            <table class="solidborder" width="100%" >
              <tr class="table_header">
                <td width="17%">Voucher Name</td>
                
                <td width="20%">Voucher Code</td>
                <td width="14%">Used By</td>
                <td width="18%">Order Number</td>
                <td width="12%">Used Datetime</td>
                          
              </tr>
		<?
			$no=$from+1;
			while($c=mysql_fetch_array($get_dv))
			{
				if($no%2==0)
				{
					$class1="table_item_even";
					$class2="table_item_odd";
				}
				else
				{
					$class1="table_item_odd";
					$class2="table_item_even";
				}
				
				$get_voucher=mysql_query("select * from os_discount_voucher where id=".$c['voucher_id']);
				$v=mysql_fetch_array($get_voucher,MYSQL_ASSOC);	
				
				
				
				
				
		?>	
		 <tr height="30" valign="top" class="<?= $class1 ?>"  onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='<?= $class1 ?>'">
			<td>
            <?
				if($v['is_birthday_voucher']==1)
				{
			?>
            <a href="bv_edit.php?id=<?= $v['id'] ?>"><?= $v['voucher_name'] ?></a>
            <? }else{ ?>
            <a href="dv_edit.php?id=<?= $v['id'] ?>"><?= $v['voucher_name'] ?></a>
            <? } ?>
            </td>
            <td ><?= $v['voucher_code'] ?></td>
            
            <td><a href="member_viewfull.php?id=<?= $c['member_id'] ?>"><?= getDataById("os_member","name","id",$c['member_id']) ?></a></td>
            <td align="center"><a href="order_viewfull.php?id=<?= $c['bill_id'] ?>"><?= getDataById("os_bill_details","invoice_number","id",$c['bill_id']) ?></a></td>    
            <td><?= $c['used_datetime'] ?></td>
            
		
		</tr>
		<? $no++;}
		?>
		</table>
		</td>
		<?
		
		} ?>
		
	</table>
	</td>
</table>

<? require("required/footer.php"); ?>

